Telegram Group & Telegram Channel
3 способа преобразования массива в объект

Приветствую товарищи! Довольно часто по разным причинам нам требуется трансформировать данные в какой-либо формат, например для работы с какой-нибудь библиотекой или апихой. В этом посте описаны 3 способа с помощью которых можно массив трансформировать в объект.

const arr = ['frontend', 'backend', 'qa'];

// 1 способ - метод assign
const obj = Object.assign({}, arr);

// 2 способ - spread оператор
const obj = {...arr};

// 3 способ - метод reduce
const obj = arr.reduce((res, key, index) => {
res[index] = key;
return res;
}, {})

#js #features



tg-me.com/projavascript/155
Create:
Last Update:

3 способа преобразования массива в объект

Приветствую товарищи! Довольно часто по разным причинам нам требуется трансформировать данные в какой-либо формат, например для работы с какой-нибудь библиотекой или апихой. В этом посте описаны 3 способа с помощью которых можно массив трансформировать в объект.

const arr = ['frontend', 'backend', 'qa'];

// 1 способ - метод assign
const obj = Object.assign({}, arr);

// 2 способ - spread оператор
const obj = {...arr};

// 3 способ - метод reduce
const obj = arr.reduce((res, key, index) => {
res[index] = key;
return res;
}, {})

#js #features

BY Javascript Pro


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/projavascript/155

View MORE
Open in Telegram


Javascript Pro Telegram | DID YOU KNOW?

Date: |

That growth environment will include rising inflation and interest rates. Those upward shifts naturally accompany healthy growth periods as the demand for resources, products and services rise. Importantly, the Federal Reserve has laid out the rationale for not interfering with that natural growth transition.It's not exactly a fad, but there is a widespread willingness to pay up for a growth story. Classic fundamental analysis takes a back seat. Even negative earnings are ignored. In fact, positive earnings seem to be a limiting measure, producing the question, "Is that all you've got?" The preference is a vision of untold riches when the exciting story plays out as expected.

The SSE was the first modern stock exchange to open in China, with trading commencing in 1990. It has now grown to become the largest stock exchange in Asia and the third-largest in the world by market capitalization, which stood at RMB 50.6 trillion (US$7.8 trillion) as of September 2021. Stocks (both A-shares and B-shares), bonds, funds, and derivatives are traded on the exchange. The SEE has two trading boards, the Main Board and the Science and Technology Innovation Board, the latter more commonly known as the STAR Market. The Main Board mainly hosts large, well-established Chinese companies and lists both A-shares and B-shares.

Javascript Pro from kr


Telegram Javascript Pro
FROM USA